package org.creavi.engine.model;

import java.io.IOException;
import java.util.ArrayList;

import com.jme.util.export.InputCapsule;
import com.jme.util.export.JMEExporter;
import com.jme.util.export.JMEImporter;
import com.jme.util.export.OutputCapsule;
import com.jme.util.export.Savable;

public class JoinPointDefinition implements Savable {
	private String name;
	
	private ArrayList<JoinPointPart> keyframes;
	
	public JoinPointDefinition() {
		
	}
	
	public JoinPointDefinition(String name) {
		this.name = name;
		keyframes = new ArrayList<JoinPointPart>();
	}

	public ArrayList<JoinPointPart> getKeyframes() {
		return keyframes;
	}

	public void setKeyframes(ArrayList<JoinPointPart> keyframes) {
		this.keyframes = keyframes;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Class<?> getClassTag() {
		return getClass();
	}

	@SuppressWarnings("unchecked")
	public void read(JMEImporter im) throws IOException {
		InputCapsule ic = im.getCapsule(this);
		name = ic.readString("name", null);
		keyframes = ic.readSavableArrayList("keyframes", new ArrayList<JoinPointPart>());
	}

	public void write(JMEExporter ex) throws IOException {
		OutputCapsule oc = ex.getCapsule(this);
		oc.write(name, "name", null);
		oc.writeSavableArrayList(keyframes, "keyframes", null);
	}
}
